/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.evosoft.service;

import com.evosoft.dao.DAOFactory;
import com.evosoft.excepciones.NotEntityFoundException;
import com.evosoft.model.Rol;
import java.util.List;
import javax.persistence.EntityManager;

/**
 *
 * @author David
 */
public class RoleService {
    private static RoleService instance;

    private RoleService() {
    }

    public synchronized static RoleService getInstance() {
        if (instance == null) {
            instance = new RoleService();
        }

        return instance;
    }

    public void crearRol(Rol rol, EntityManager em) {
        DAOFactory.getInstance().getRolDAO().create(rol, em);
    }

    public List<Rol> obtenerRoles(EntityManager em) {
        return DAOFactory.getInstance().getRolDAO().findAll(em);
    }

    public List<Rol> obtenerRolesPorEmpresa(int id, EntityManager em) throws NotEntityFoundException {
        return DAOFactory.getInstance().getRolDAO().obtenerPorEmpresa(id, em);
    }
}
